package com.yunhe.estatemanage.client;

import com.yunhe.common.exception.ObjectNotFoundException;
import com.yunhe.common.model.ResultObject;
import com.yunhe.common.model.authority.MessageCenter;
import com.yunhe.common.model.authority.RealStation;
import com.yunhe.common.model.authority.User;
import com.yunhe.common.model.authority.UserProjectOrg;
import com.yunhe.common.model.company.Company;
import com.yunhe.estatemanage.client.fallback.AuthorityClientFallbackFactory;
import com.yunhe.estatemanage.config.FeignConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;
import java.util.Map;

/**
 * @ClassName: AuthorityClient
 * @Description:
 * @author: GongDaCheng
 * @Date: 9:57 2021/9/8
 */
@ApiIgnore
@FeignClient(value = "yh-authority", fallbackFactory = AuthorityClientFallbackFactory.class,configuration = FeignConfig.class)
@Component
public interface AuthorityClient {

    /**
     * 查询真实园区（携带厂房）
     * @param stationId 总园区ID
     */
    @RequestMapping(value = "/realStation/searchStationAndOfficeByStationId/{stationId}", method = RequestMethod.GET)
    ResponseEntity<ResultObject> searchStationAndOfficeByStationId(@PathVariable("stationId") Long stationId);

    @PostMapping("/messageCenter/batchCreateMessageCenter")
    ResponseEntity<ResultObject<Iterable<MessageCenter>>> batchCreateMessageCenter(@RequestBody List<MessageCenter> dataLists);

    @GetMapping(value = "/users/findStationUserByStationId")
    ResponseEntity<ResultObject<List<User>>> findStationUserByStationId(@RequestParam(value = "stationId",required = true) Long stationId);

    @RequestMapping(value = "/users/getUserByOrgIdAndStationId", method = RequestMethod.GET)
    ResponseEntity<ResultObject<List<UserProjectOrg>>> getUserByOrgIdAndStationId(@RequestParam(value = "orgId",required = true) Long orgId,
                                                                                  @RequestParam(value = "stationId",required = true) Long stationId);

    @RequestMapping(value = "/companys/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<Company>> getCompanyById(@PathVariable("id") Long id);

    @RequestMapping(value = "/realStation/searchById/{id}", method = RequestMethod.GET)
    ResponseEntity<ResultObject<RealStation>> searchRealStationById(@PathVariable("id") Long id);

    /************消息推送***************/

    /**
     * 根据用户Ids推送消息
     * @param userIds 用户Ids
     * @param notificationTitle 通知标题
     * @param msgContent 消息内容
     * @param extras 额外字段
     * @return ResponseEntity<ResultObject>
     */
    @RequestMapping(value = "/appPush/pushMessageByUserIds", method = RequestMethod.POST)
    ResponseEntity<ResultObject> pushMessageByUserIds(@RequestParam("userIds") String userIds,
                                                      @RequestParam("notificationTitle") String notificationTitle,
                                                      @RequestParam("msgContent") String msgContent,
                                                      @RequestBody() Map<String, String> extras);

    /**
     * 根据虚拟园区id推送消息
     * @param stationId 虚拟园区ID
     * @param notificationTitle 通知标题
     * @param msgContent 消息内容
     * @param extras 额外字段
     * @return ResponseEntity<ResultObject>
     */
    @RequestMapping(value = "/appPush/pushMessageByStationId", method = RequestMethod.POST)
    ResponseEntity<ResultObject> pushMessageByStationId(@RequestParam("stationId") Long stationId,
                                                        @RequestParam("notificationTitle") String notificationTitle,
                                                        @RequestParam("msgContent") String msgContent,
                                                        @RequestBody() Map<String, String> extras);
}
